package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Auther: Tangguo
 * @Date: 2023-06-08  14:39
 */

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 上传素材图片
     * @param multipartFile:
     * @return ResponseResult
     */
    @PostMapping("/upload_picture")
    public ResponseResult upload(@RequestParam("multipartFile") MultipartFile multipartFile){
        return wmMaterialService.upload(multipartFile);
    }


    /**
     * 素材列表查询
     * @param dto:
     * @return ResponseResult
     */
    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto dto){

        return wmMaterialService.findList(dto);
    }

    /**
     * 删除素材
     * @param id:
     * @return ResponseResult
     */
    @GetMapping("/del_picture/{id}")
    public ResponseResult delete(@PathVariable Integer id){
      return wmMaterialService.delete(id);

    }

    /**
     * 收藏素材
     * @param id:
     * @return ResponseResult
     */
    @GetMapping("/collect/{id}")
    public ResponseResult collect(@PathVariable Integer id){
        return wmMaterialService.collect(id);

    }

    /**
     * 取消收藏素材
     * @param id:
     * @return ResponseResult
     */
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable Integer id){
        return wmMaterialService.cancelCollect(id);

    }


}
